<?php
namespace app\api\controller;

use app\api\model\CouponModel;
use think\Controller;
use think\Request;

class Coupon extends Controller
{
   /**
    * 优惠券类
    *
    * 优惠券列表
    */
    public function couponList(Request $request){
        $bid = $request->get('bid');
        if(empty($bid)) $this->outPut('', 1001, ":缺少参数 bid");
        $result = CouponModel::instance()->couponlist($bid);
        $this->jsonOut($result);

    }
    /**
     * 领取优惠券
     */
    public function getcoupon(Request $request){
        $disid = $request->get('disid');
        if(empty($disid)) $this->outPut('', 1001, ":缺少参数 disid");
        list($result,$code) = CouponModel::instance()->getcoupon($disid,$this->uid);
        if($result == false)  $this->outPut(null,$code);
        if($result == 1){
            $this->jsonOut($result);
        }else{
            $this->outPut(null,0);
        }

    }
}
